<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    let arr = []
        let combine = function (str) {
            for (let i = 0; i < str.length; i++) {
                for (let j = 0; j < str.length; j++) {
                    if (i != j) {
                        for (let k = 0; k < str.length; k++) {
                            if (i != k && j != k) {
                                console.log(str[i]+str[j]+str[k]) 
                                arr.push(str[i]+str[j]+str[k])
                            }
                        }
                    }
                }
            }
        }
        combine(['a','b','ab'])
        console.log(Array.from(new Set(arr)))
</script>